function model = sc_train(feat_train, score_train)

feat_train = feat_train';

data_n = size(feat_train,2);
dim = size(feat_train,1);

repeat_n = 1;

feat_mean = mean(feat_train,2);
model.feat_mean = feat_mean;
model.score_mean = mean(score_train,1);

feat_mean = repmat( feat_mean, 1 ,data_n);


feat_train = feat_train - feat_mean ;

feat_train = repmat( feat_train, 1 , repeat_n );

%feat_train = feat_train + rand(size(feat_train)) * 0.01;

num_bases = 15;

beta = 0.2;

batch_size = data_n;

num_iters = 10;

sparsity_func= 'L1';

epsilon = [];
Binit = [];

fname_save = sprintf( ...   
    './method/sc_%s_b%d_beta%g_%s', ...
    sparsity_func, num_bases, beta, datestr(now, 30));

warning close
[model.S model.B  stat] = sparse_coding(feat_train, num_bases, beta, sparsity_func, epsilon, num_iters, batch_size, fname_save, Binit);
warning on

model.S = model.S';
model.B = model.B';
%B * S = feat_train
%B * [S Q] = [feat_train score_train]
% B * Q = score_train

B = model.B;

model.Q =  inv(B'*B) * B' * score_train;